#include <iostream>
#include <string>
#include <sstream>
#include <vector>

int check(std::vector<int> &nums, int k)
{
    int step = 1;

    int i = k;
    while (i < nums.size() - 1)
    {
        i += nums[i];
        step++;
    }

    if (i == nums.size() - 1)
    {
        return step;
    }
    else
    {
        return 1e9;
    }
}

int main()
{
    std::string input;
    std::getline(std::cin, input);
    std::istringstream istr;
    istr.str(input);

    int num;
    std::vector<int> nums;
    while (istr >> num)
    {
        nums.push_back(num);
    }

    int min_step = 1e9;
    for (int i = 1; i < nums.size() / 2; i++)
    {
        int ret = check(nums, i);
        min_step = std::min(min_step, ret);
    }

    if (min_step == 1e9)
    {
        std::cout << -1 << std::endl;
    }
    else
    {
        std::cout << min_step << std::endl;
    }

    return 0;
}